package com.nexfra.bbssys.common.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.nexfra.bbssys.common.dao.CommonDao;
import com.nexfra.bbssys.common.domain.AttachFile;

@Service
public class CommonService {
	@Autowired
	private CommonDao commonDao;

	/**
	 * TOP메뉴를 조회한다.
	 * @return List<Map<String,Object>>
	 */
	public List<Map<String,Object>> selectTopMenuList(HashMap<String, String> sqlParams) {
		return commonDao.selectTopMenuList(sqlParams);
	}

	/**
	 * Left메뉴를 조회한다. 
	 * @return List<Map<String,Object>>
	 */
	public List<Map<String,Object>> selectLeftMenuList(HashMap<String, String> sqlParams) {
		return commonDao.selectLeftMenuList(sqlParams);
	}
	
////////////////////////////////////////////////////////////////////////////////	
	
	/**
	 * 사용자 메뉴를 조회한다.
	 * @return List<Map<String,Object>>
	 */
/*	public List<Map<String,Object>> getMenuList(HashMap<String, String> sqlParams) {
		return commonDao.getMenuList(sqlParams);
	}*/


	/**
	 * 공통코드를 조회한다.
	 * @return List<Map<String,Object>>
	 */
	public List<Map<String,Object>> selectCommonCode(HashMap<String, String> sqlParams) {
		return commonDao.selectCommonCode(sqlParams);
	}
	
	/**
	 * 첨부파일을 조회한다.
	 * @return List<AttachFile>
	 */
	public List<AttachFile> selectAttachFile(HashMap<String, String> sqlParams) {
		return commonDao.selectAttachFile(sqlParams);
	}
	
	/**
	 * 개인화정보를 조회한다. 
	 * @return List<Map<String,Object>>
	 */
	public List<Map<String,Object>> getPsersonalConfig(HashMap<String, String> sqlParams) {
		return commonDao.getPsersonalConfig(sqlParams);
	}
	
	/**
	 * 개인화정보를 저장한다. 
	 * @return List<Map<String,Object>>
	 */
	@Transactional(rollbackFor = Exception.class) 
	public void savePersonalConfig(HashMap<String, String> sqlParams) 
		throws Exception {
		commonDao.deletePersonalConfig(sqlParams);
		commonDao.insertPersonalConfig(sqlParams);
	}	
}
